package com.dlwx.parttimetalent.views;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.NumberPicker;
import android.widget.TextView;

import com.dlwx.parttimetalent.R;
import com.dlwx.parttimetalent.inter.DialogInter;
import com.flyco.dialog.widget.base.BaseDialog;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by Administrator on 2017/11/22.
 */

public class TimeOrderDialog extends BaseDialog {
    @BindView(R.id.np_time)
    MyNumberPicker npTime;
    @BindView(R.id.tv_cancel)
    TextView tvCancel;
    @BindView(R.id.tv_confirm)
    TextView tvConfirm;
    private Context context;
    private String[] times;
    private boolean isDay=false;
    private DialogInter inter;

    public TimeOrderDialog(Context context, boolean isDay, DialogInter inter) {
        super(context);
        this.context = context;
        this.isDay=isDay;
        this.inter=inter;
    }

    @Override
    public View onCreateView() {
        widthScale(0.85f);
        View view = LayoutInflater.from(context).inflate(R.layout.dialog_time,null);
        ButterKnife.bind(this, view);
//        initView();
        return view;
    }

    private void initView() {

    }

    @Override
    public void setUiBeforShow() {
        if(isDay){
            times = new String[]{"5天","6天","7天","8天","9天","10天","11天","12天","13天","14天","15天","30天"};
        }else{
            times = new String[]{"5小时","6小时","7小时","8小时"};
        }

        npTime.setDisplayedValues(times);
        npTime.setMinValue(0);
        npTime.setMaxValue(times.length - 1);
        npTime.setValue(0);
        npTime.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);
    }

    @OnClick({R.id.tv_cancel, R.id.tv_confirm})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.tv_cancel:
                this.dismiss();
                break;
            case R.id.tv_confirm:
                inter.getInfo(times[npTime.getValue()]);
                this.dismiss();
                break;
        }
    }
}
